package io.renren;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.util.StringUtils;

import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication(exclude = {MongoAutoConfiguration.class, MongoDataAutoConfiguration.class})
@MapperScan("io.renren.dao")
public class ZzwCodeGenerationApplication {

	public static void main(String[] args) throws UnknownHostException {
		ConfigurableApplicationContext context = SpringApplication.run(ZzwCodeGenerationApplication.class, args);
		Environment environment = context.getEnvironment();
//		 Iterator<String> iterator = context.getBeanFactory().getBeanNamesIterator();
//		 while (iterator.hasNext()) {
//		 	System.out.println(iterator.next());
//		 }
		String ip = InetAddress.getLocalHost().getHostAddress();
		String port = environment.getProperty("server.port");
		String path = environment.getProperty("server.servlet.context-path");
		if (!StringUtils.hasLength(path) || "/".equals(path)) {
			path = "";
		}
		System.out.println(("\n----------------------------------------------------------\n\t" +
				"zzw-generator:代码生成器 --->启动成功 URLs:\n\t" +
				"生成文档地址址: \t\thttp://" + ip + ":" + port + path + "\n" +
				"----------------------------------------------------------"));
	}
}
